<template>
  <el-dialog
    v-model="dialogVisible"
    :width="width"
    align-center
    :close-on-click-modal="false"
  >
    <template #header>
      <div class="dialog-header">{{ title }}</div>
    </template>
    <slot></slot>
    <template #footer >
      <span class="dialog-footer">
        <el-button @click="handleClickCancel">{{ cancelText }}</el-button >
        <el-button type="primary" @click="handleClickConfirm"  v-if="showCancel">{{ confirmText }}</el-button>
      </span>
    </template>
  </el-dialog>
</template>
<script setup>
const props = defineProps({
  title: {
    type: String,
    default: "Title",
  },
  width: {
    type: String,
    default: "46%",
  },
  footerCustom: {
    type: Boolean,
    default: false,
  },
  visible: {
    type: Boolean,
    default: false,
  },
  showCancel: {
    type: Boolean,
    default: true,
  },
});

const cancelText = inject("cancelText", "取消");
const confirmText = inject("confirmText", "保存");

const dialogVisible = computed({
  get() {
    return props.visible;
  },
  set(val) {
    emits("update:visible", val);
  },
});

const emits = defineEmits([
  "handleClickCancel",
  "handleClickConfirm",
  "update:visible",
]);

const handleClickCancel = (v) => {
  dialogVisible.value = false;
  emits("handleClickCancel", props.visible);
};

const handleClickConfirm = (v) => {
  emits("handleClickConfirm");
};
</script>

<style lang="scss" scoped>



</style>
